<?php
class Form_Project extends Zend_Form
{
    public function __construct($options=array())
    {
		parent::__construct($options);
		
		Zend_Loader::loadClass('Customer', array('../application/default/models/'));
		Zend_Loader::loadClass('User', array('../application/default/models/'));
		$this->setMethod('post');
		$mod_customer = new Customer();
		$mod_user = new User();
		$cust_arr = $mod_customer->listCustomers();
		$user_bse_arr = $mod_user->viewBSEUsers();
		$user_pl_arr = $mod_user->viewPLUsers();
		$user_dev_arr = $mod_user->viewDEVUsers();		
		
		$this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');	
	   
	    $this->addElement('text', 'project_title', array(
            'label'      => 'Project Title	',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'class'		 => 'inp-form',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
		
        // add project type
		$project_type = new Zend_Form_Element_Select('project_type');
        $project_type ->setLabel('Project Type')
		 			  ->addMultiOptions(array(
		 			    '' => 'Select Project Type',            
						'sap' => 'SAP',
						'accpac' => 'Accpac',
						'sap_development' => 'SAP + Development',
						'accpac_development' => 'Accpac + Development',
						'sap_support' => 'SAP Support Service',
						'accpac_support' => 'Accpac Support Service',
						'devlopment' => 'Development'));
		
		$this->addElement($project_type);
		
		// add customer 
		$customer = new Zend_Form_Element_Select('customer_id');
		$customer ->setLabel('Customer');
		$customer->setOptions(array('class'=>'input-2'));
		
		$customer->addMultiOption('', 'Select Customer'); 		  
        foreach ($cust_arr as $cust_entry)
		{
			$customer->addMultiOption($cust_entry['customer_id'], $cust_entry['customer_name']);
		}
		
		$this->addElement($customer);
        
        // add bse list
		$user_bse = new Zend_Form_Element_Select('bse_id');
		$user_bse ->setLabel('Business Solution Executive (BSE)');
		$user_bse->setOptions(array('class'=>'input-2'));
		
		$user_bse->addMultiOption('', 'Select BSE'); 		  
        foreach ($user_bse_arr as $user_arr)
		{
			$user_name = $user_arr['first_name'] . " " . $user_arr['last_name'];
			$user_bse->addMultiOption($user_arr['userid'], $user_name);
		}
		
		$this->addElement($user_bse);
		
		// add pl list
		$user_pl = new Zend_Form_Element_Select('pl_id');
		$user_pl ->setLabel('Project Leader (PL)');
		$user_pl->setOptions(array('class'=>'input-2'));
		
		$user_pl->addMultiOption('', 'Select PL'); 		  
        foreach ($user_pl_arr as $user_arr)
		{
			$user_name = $user_arr['first_name'] . " " . $user_arr['last_name'];
			$user_pl->addMultiOption($user_arr['userid'], $user_name);
		}
		
		$this->addElement($user_pl);
		
		// add dev list
		$user_dev = new Zend_Form_Element_Select('dev_id');
		$user_dev ->setLabel('Developer');
		$user_dev->setOptions(array('class'=>'input-2'));
		
		$user_dev->addMultiOption('', 'Select Devloper'); 		  
        foreach ($user_dev_arr as $user_arr)
		{
			$user_name = $user_arr['first_name'] . " " . $user_arr['last_name'];
			$user_dev->addMultiOption($user_arr['userid'], $user_name);
		}
		
		$this->addElement($user_dev);
			
		$status = new Zend_Form_Element_Select('status');
        $status ->setLabel('Status')
		 			 ->addMultiOptions(array(
						'' => 'Select Project Status',
		 			    1 => 'Active',
						0 => 'Pending'));
						
		$this->addElement($status);
		
    }
}
